package com.zhongketech.sunflower.control;

import java.util.List;

import com.zhongketech.sunflower.Constant;
import com.zhongketech.sunflower.sv.SvManager;
import com.zhongketech.sunflower.transport.LogUtil;
import com.zhongketech.sunflower.transport.model.SpecialNums;

public class PhoneManager {

	private static final String TAG = "PhoneManager";
	private static PhoneManager instance = new PhoneManager();

	private boolean isPhoneEnable = false;
	private boolean isSmsEnable = false;
	private List<SpecialNums> numList;;


	private PhoneManager()
	{

	}

	public static PhoneManager getInstance()
	{
		return instance;
	}

	public List<SpecialNums> getNumList() {
		return numList;
	}

	public void setNumList(List<SpecialNums> numList) {
		numList = numList;
	}

	public boolean isBlack(String num)
	{
		if(null == num)
		{
			return false;
		}

		//check white list
		LogUtil.i("ZK","phonemanager isBlack: "+num);
		List<SpecialNums> list = SpecialNumsManager.getSpecialNums(Constant.SN_BLACK);
		for(int i = 0;null != list && i < list.size() ;i ++)
		{
			if(num.equals(list.get(i).getPhone()))
			{
				return true;
			}
		}

		return false;
	}

	public boolean isExist(String num) {

		if(null == num ||(!SvManager.getInstance().isPhoneEnable()))
		{
			return true;
		}

		//check white list
		LogUtil.i("ZK","phonemanager isExist: "+num);
		List<SpecialNums> list = SpecialNumsManager.getSpecialNums(Constant.SN_FAMILY);
		for(int i = 0;null != list && i < list.size() ;i ++)
		{
			if(num.equals(list.get(i).getPhone()))
			{
				return true;
			}
		}

		list = SpecialNumsManager.getSpecialNums(Constant.SN_EMERGENCY);
		for(int i = 0;null != list && i < list.size() ;i ++)
		{
			if(num.equals(list.get(i).getPhone()))
			{
				return true;
			}
		}

		return false;
	}
}
